import {tokenCookies} from "../cookies";
import {showFullScreenLoading} from "./loading";
import config from '#/utils/config'


const tokenName = config.tokenName
console.log('tokenName', tokenName)
export function requestInterceptors(config) {

    // 默认全局Content-Type = application/json;charset=utf-8
    // 默认get和options， application/x-www-form-urlencoded;charset=utf-8
    // if(config.method === 'options' || config.method === 'get') {
    //     config.headers[ 'Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'
    // }

    // 获取token
    config.headers[tokenName] = tokenCookies.getToken() || null


    // 配置loading加载
    const loadingMessage = config['loadMsg'] || null
    loadingMessage && showFullScreenLoading('body', loadingMessage)


    return config;
}

